package com.framework.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.framework.core.log.annotation.AutoLog;
import com.framework.core.result.R;
import com.framework.system.entity.dto.SysAreaQueryDTO;
import com.framework.system.entity.vo.SysAreaListVO;
import com.framework.system.service.ISysAreaService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 行政区域管理
 *
 * @author Kevin
 * @since 2021-08-08
 */
@RestController
@RequestMapping("/system/sysArea")
@AllArgsConstructor
public class SysAreaController {

    private ISysAreaService sysAreaService;

    /**
     * 分页查询行政区域列表
     */
    @GetMapping("/selectSysAreaWithPage")
    @SaCheckPermission("system:sysArea:selectSysAreaWithPage")
    @AutoLog(module = "行政区域", title = "分页查询行政区域列表")
    public R<Page<SysAreaListVO>> selectSysAreaWithPage(Page reqPage, SysAreaQueryDTO req) {
        return R.success(sysAreaService.selectSysAreaWithPage(reqPage, req));
    }

    /**
     * 查询行政区域树
     */
    @GetMapping("/selectSysAreaWithTree")
    @AutoLog(module = "行政区域", title = "查询区域树")
    public R<List<Tree<String>>> selectSysAreaWithTree() {
        return R.success(sysAreaService.selectSysAreaWithTree());
    }

}

